<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>天气预报</title>
    <script src="/webjars/jquery/3.4.1/jquery.js" type="text/javascript"></script>
</head>
<body>
请输入要查询的城市天气:
<input id="cityName" type="text" value=""><button  onclick="search()">点击查询</button><br/>
今天时间:<input id="time" type="text" value=""><br/>
星期:<input id="day" type="text" value=""><br/>
是否炎热:<input id="hold" type="text" value=""><br/>
出门建议:<input id="divice" type="text" value=""><br/>
温度:<input id="temperature" type="text" value=""><br/>
天气:<input id="weather" type="text" value=""><br/>
风向:<input id="wind" type="text" value=""><br/>




</body>
<script type="text/javascript">
    /*
    查询天气
     */
    function search() {
        var cityName=$("#cityName").val();
        console.log(cityName)
        $.ajax({
            url:"getDataByCity",
            type:"post",
            data:{
                "cityName":cityName
            },
            dataType:"json",
            success:function (result) {
                // console.log(result);
                console.log(result.result.today)
                var today=result.result.today;
                $("#time").val(today.date_y);
                $("#hold").val(today.dressing_index);
                $("#day").val(today.week);
                $("#wind").val(today.wind);
                $("#temperature").val(today.temperature);
                $("#weather").val(today.weather);
                $("#divice").val(today.dressing_advice);


            }

        });
    }

</script>
</html>